package _220320;

/**
 * @author ShadowLim
 * @create 2022-03-20-10:33
 */
public class 方格分割 {
    static int ans = 0;
    static int[][] dirs = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    static boolean[][] vis = new boolean[7][7];

    public static void main(String[] args) {
        vis[3][3] = true;
        dfs(3, 3);  // 从中心N/2开始进行深搜
        System.out.println(ans / 4);
    }

    private static void dfs(int x, int y) {
        if (x == 0 || y == 0 || x == 6 || y == 6) {
            ans++;
            return;
        }
        vis[x][y] = true;
        vis[6 - x][6 - y] = true;
        for (int i = 0; i < 4; i++) {
            int nx = x + dirs[i][0];
            int ny = y + dirs[i][1];
            if (nx < 0 || nx > 6 || ny < 0 || ny > 6) {
                continue;
            }
            if (!vis[nx][ny]) {
                dfs(nx, ny);
            }
        }
        vis[x][y] = false;
        vis[6 - x][6 - y] = false;
    }
}
